#[derive(Debug)]
struct Person<'a> {
    name: &'a str,
    age: u8,
}

struct Nil;

struct Pair(i32, f32);

struct Point {
    x: f32,
    y: f32,
}

struct Rectangle {
    p1: Point,
    p2: Point,
}

impl Rectangle {
    fn area(&self) -> f32 {
        self.p2.x * self.p1.x
    }
}

fn main() {
    println!("Hello, world!");
    let name = "Peter";
    let age = 27;
    let peter = Person { name, age };
    println!("{:#?}", peter);

    let point: Point = Point { x: 0.3, y: 0.4 };
    println!("点坐标（{} , {}）", point.x, point.y);

    let new_point = Point { x: 0.1, ..point };
    println!("第二个坐标({} , {})", new_point.x, new_point.y);

    let Point { x: my_x, y: my_y } = point;
    println!("解构出来的值({} , {})", my_x, my_y);
    let _rectangle = Rectangle {
        p1: Point { x: my_x, y: my_y },
        p2: point,
    };
    println!("{}", _rectangle.area());
    let _nil = Nil;
    let pair = Pair(1, 0.1);

    println!("pair contains {:?} and {:?}", pair.0, pair.1);
    let Pair(integer, decimal) = pair;
    println!("pair contains {:?} and {:?}", integer, decimal);
}
